package mobilefeel.sdk;

import mobilefeel.dto.DataTransferObject;
import mobilefeel.dto.TouchEvent;
import mobilefeel.dto.ViewEvent;

final class TouchScreenController {
	
	private MobileFeelService service;
	private NetworkController network;
	
	TouchScreenController(MobileFeelService service, NetworkController network){
		this.service = service;
		this.network = network;
	}

	void registerView(int id, String name, int width, int height) {
		ViewEvent viewEvent = new ViewEvent();
		viewEvent.setType(DataTransferObject.TOUCHSCREEN_REGISTER_VIEW);
		viewEvent.setDeviceId(service.getDeviceId());
		viewEvent.setId(id);
		viewEvent.setName(name);
		viewEvent.setWidth(width);
		viewEvent.setHeight(height);
		network.sendObject(viewEvent);
	}

	void onClick(int id) {
		ViewEvent viewEvent = new ViewEvent();
		viewEvent.setType(DataTransferObject.TOUCHSCREEN_CLICK_EVENT);
		viewEvent.setDeviceId(service.getDeviceId());
		viewEvent.setId(id);
		network.sendObject(viewEvent);
	}
	
	void onLongClick(int id) {
		ViewEvent viewEvent = new ViewEvent();
		viewEvent.setType(DataTransferObject.TOUCHSCREEN_LONGCLICK_EVENT);
		viewEvent.setDeviceId(service.getDeviceId());
		viewEvent.setId(id);
		network.sendObject(viewEvent);
	}
	
	void onTouch(int id, TouchEvent touchEvent) {
		touchEvent.setType(DataTransferObject.TOUCHSCREEN_TOUCH_EVENT);
		touchEvent.setDeviceId(service.getDeviceId());
		touchEvent.setId(id);	
		network.sendObject(touchEvent);
	}

}